<template>
    <div class="">
        <avue-form :option="option" v-model="form" @submit="submit"></avue-form>
    </div>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'

const props = defineProps(['modelValue', 'initialized'])
const emit = defineEmits(['update:modelValue', 'submit'])

const form = ref<any>({
    chromaUrl: '',
    uploadBaseUrl: '',
})

const option = ref({
    emptyBtn: false,
    submitText: '保存',
    labelWidth: 200,
    column: [
        {
            label: '上传BaseUrl',
            prop: 'uploadBaseUrl',
            span: 24,
        },
        {
            label: '向量数据库chroma地址',
            prop: 'chromaUrl',
            span: 24,
        },
    ],
})

watch(
    () => props.modelValue,
    (newVal) => {
        if (newVal) {
            form.value.chromaUrl = newVal.chromaUrl
            form.value.uploadBaseUrl = newVal.uploadBaseUrl
        }
    }
)

const submit = (form, done) => {
    emit('submit', form, done)
}
</script>
